﻿using HZH_Controls.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TreeExHZL
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 4; i++)
            {
                TreeNode tn = new TreeNode("  父节点" + i);
                for (int j = 0; j < 3; j++)
                {
                    tn.Nodes.Add("    子节点" + j);
                }
                this.treeViewEx1.Nodes.Add(tn);
            }
            TreeNode tn1 = new TreeNode("  父节点" + 4);
            this.treeViewEx1.Nodes.Add(tn1);
            this.treeViewEx1.LstTips.Clear();
            this.treeViewEx1.LstTips.Add("  父节点0", "0000000000000000000000");
            this.treeViewEx1.LstTips.Add("  父节点1", "111111111111111111111111111");
            Dictionary<string, string> m_dataSource = new Dictionary<string, string>();
            m_dataSource.Add("父节点0", "1");
            m_dataSource.Add("父节点1", "2");
            m_dataSource.Add("父节点2", "3");
            m_dataSource.Add("父节点3", "4");

            ucBtnsGroup1.DataSource = m_dataSource;
            List<KeyValuePair<string, string>> lstHL = new List<KeyValuePair<string, string>>();
            for (int i = 0; i < 30; i++)
            {
                lstHL.Add(new KeyValuePair<string, string>(i.ToString(), "选项" + i));
            }

            this.ucHorizontalList1.DataSource = lstHL;
            List<ListEntity> lst = new List<ListEntity>();
            for (int i = 0; i < 5; i++)
            {
                lst.Add(new ListEntity()
                {
                    ID = i.ToString(),
                    Title = "选项" + i,
                    ShowMoreBtn = true,
                    Source = i
                });
            }
            this.ucListExt1.SetList(lst);
            List<Object> lstInt = new List<Object>();
            for (int i = 0; i < 12; i++)
            {
                lstInt.Add(i);
            }
            ucPagerControl21.DataSource = lstInt;

            List<MenuItemEntity> lstMenu = new List<MenuItemEntity>();
            for (int i = 0; i < 5; i++)
            {
                MenuItemEntity item = new MenuItemEntity()
                {
                    Key = "p" + i.ToString(),
                    Text = "菜单项" + i,
                    DataSource = "这里编写一些自定义的数据源，用于扩展"
                };
                item.Childrens = new List<MenuItemEntity>();
                for (int j = 0; j < 5; j++)
                {
                    MenuItemEntity item2 = new MenuItemEntity()
                    {
                        Key = "c" + i.ToString(),
                        Text = "菜单子项" + i + "-" + j,
                        DataSource = "这里编写一些自定义的数据源，用于扩展"
                    };
                    item.Childrens.Add(item2);
                }
                lstMenu.Add(item);
            }
            this.ucMenu1.MenuStyle = MenuStyle.Fill;
            this.ucMenu1.DataSource = lstMenu;

            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "ID", HeadText = "编号", Width = 70, WidthType = SizeType.Absolute });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = 50, WidthType = SizeType.Percent });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Age", HeadText = "年龄", Width = 50, WidthType = SizeType.Percent });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Birthday", HeadText = "生日", Width = 50, WidthType = SizeType.Percent, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd"); } });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Sex", HeadText = "性别", Width = 50, WidthType = SizeType.Percent, Format = (a) => { return ((int)a) == 0 ? "女" : "男"; } });
            this.ucDataGridView1.Columns = lstCulumns;
            this.ucDataGridView1.IsShowCheckBox = true;
            List<object> lstSource = new List<object>();
            for (int i = 0; i < 200; i++)
            {
                TestModel model = new TestModel()
                {
                    ID = i.ToString(),
                    Age = 3 * i,
                    Name = "姓名——" + i,
                    Birthday = DateTime.Now.AddYears(-10),
                    Sex = i % 2
                };
                lstSource.Add(model);
            }

            var page = new UCPagerControl2();
            page.DataSource = lstSource;
            this.ucDataGridView1.Page = page;
            this.ucDataGridView1.First();
        }

        private void ucBtnExt1_BtnClick(object sender, EventArgs e)
        {
            MessageBox.Show("点击了按钮");
        }

        private void ucCheckBox1_Load(object sender, EventArgs e)
        {

        }

        private void ucCheckBox1_CheckedChangeEvent(object sender, EventArgs e)
        {

        }

        private void ucControlBase1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            processExt1.Step();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FrmAnchor frmAnchor=new FrmAnchor(button2, new Size(300, 300));
            if (!frmAnchor.Visible)
                frmAnchor.Show(this.FindForm());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            FrmTips.ShowTipsError(this, "Error提示信息");
            //FrmTips.ShowTipsInfo(this, "Info提示信息");
            //FrmTips.ShowTipsInfo(this, "Info提示信息");
        }
    }
}
